<%@ page 
language="java" 
import="java.util.*" 
import="com.csd.helper.IConstant"
import="com.csd.helper.Tool"
import="com.csd.pojo.News"
import="com.csd.vo.UserVO"
pageEncoding="UTF-8"
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

HttpSession s = request.getSession();
UserVO uvo =  (UserVO)s.getAttribute(IConstant.userVO);

List<News> newsList = (List<News>)request.getAttribute("newsList");

int nl = 3;

if(uvo!=null && uvo.getType().equals(IConstant.managerRole) )
{
	nl = 4;
}

Integer currPage = (Integer)request.getAttribute("currPage");
Integer totalPage = (Integer)request.getAttribute("totalPage");

if(currPage == null || currPage <= 0 )
	currPage = 1;
	
if(totalPage == null || totalPage <= 0)
	totalPage = 1;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>    
    <title>新闻列表</title>
	<link rel="stylesheet" type="text/css" href="<%=path %>/common/css/rpms_right.css" />
  </head>
  
  <body>
  	<div class="main">
  		<h1>新闻列表</h1>
  		<hr />
  		<table width="100%">
  			<%if( uvo!=null ) {%>
  			<% 	String backPage =  path + "/common/newsList.jsp";%>
  			<%
				if(uvo.getType() == IConstant.managerRole)
				{
					backPage = path + "/admin/welcome.jsp";
				}
				if(uvo.getType() == IConstant.teacherRole)
				{
					backPage = path + "/teacher/index.jsp";
				}
				if(uvo.getType() == IConstant.teamRole)
				{
					backPage = path + "/team/index.jsp";
				}
			%>
  			<tr>
  			</tr>
  			<%} %>
  			<tr>
  				<td class="tbale_head" width="300px">标题</td>
  				<td class="tbale_head">发布时间</td>
  				<td class="tbale_head">发布者</td>
  			<%if(nl==4 ) { %>
  				<td class="tbale_head">删除</td>
  			<%}%>  				
  			</tr>
  			<%if(newsList != null && newsList.size()>0) {%>
  			<%for(News i :  newsList) {%>
  			<tr>
  				<td><a href="<%=path %>/newsDetail.action?newsID=<%=i.getId() %>"><%=i.getTitle() %></a></td>
  				<td><%=Tool.dateToString(i.getTime()) %></td>
  				<td><%=i.getPublisher() %></td>
  			<%if(nl==4 ) { %>
  				<td>
  					<a href="<%=path %>/newsDelete.action?newsID=<%=i.getId() %>">删除</a>
  				</td>
  			<%}%>  
  			</tr>
  			<%}}else{ %>
  			<tr>
  				<td align="center" colspan="<%=nl %>">暂无记录</td>
  			</tr>
  			<%} %>
  			<tr>
				<td colspan="<%=nl %>">
					<%if(currPage > 1){%>
					<a href="<%=path %>/newsList.action?currPage=1">首页</a> |
					<a href="<%=path %>/newsList.action?currPage=<%=currPage-1 %>">上一页</a> |
					<%} %>
					<span> 页面: <%=currPage %> </span>
					<%if(currPage < totalPage){%>
					| <a href="<%=path %>/newsList.action?currPage=<%=currPage+1 %>">下一页</a>
					| <a href="<%=path %>/newsList.action?currPage=<%=totalPage %>">尾页</a>
					<%} %>
				</td>
			</tr>
  		</table>
  	</div>    
  </body>
</html>
